//
//  QZBmobTool.m
//  bmobTest(nopod)
//
//  Created by 000 on 16/11/16.
//  Copyright © 2016年 faner. All rights reserved.
//

#import "QZBmobTool.h"

@implementation QZBmobTool
+ (void)bmobWithQueryClassName:(NSString *)className orderByAscending:(NSString *)Ascending whereKey:(NSString *)loginUser equalTo:(id)userDefaults setObject:(NSString *)setObject updateKey:(NSString *)updateKey
{
    BmobQuery *bquery = [BmobQuery queryWithClassName:className];
    [bquery orderByAscending:Ascending];
    [bquery whereKey:loginUser equalTo:userDefaults];
    [bquery calcInBackgroundWithBlock:^(NSArray *array, NSError *error) {
        NSString *thiredId;
        for (BmobObject *obj in array) {
            thiredId = [obj objectForKey:@"objectId"];
            [bquery getObjectInBackgroundWithId:[obj objectForKey:@"objectId"] block:^(BmobObject *object, NSError *error) {
                if (error) {
                }else {
                    if (object) {
                        
                        BmobObject *obj2 = [BmobObject objectWithoutDataWithClassName:object.className objectId:object.objectId];
                        [obj2 setObject:setObject forKey:updateKey];
                        //异步更新数据
                        [obj2 updateInBackground];
                    }
                }
            }];
        }
    }];
    
}
+ (void)bmobWithSetObjectClassName:(NSString *)MyclassName setObject:(id)MyuserDefaults forKey:(NSString *)loginUser setObjectFir:(id)firObject forKey:(NSString *)firKey setObjectSec:(id)secObject forKey:(NSString *)secKey setObjectThir:(id)thirObject forKey:(NSString *)ThirKey setObjectFour:(id)fourObject forKey:(NSString *)fourKey setObjectFive:(id)fiveObject forKey:(NSString *)fiveKey setObjectSix:(id)sixObject forKey:(NSString *)sixKey
{
    BmobObject *setObject = [BmobObject objectWithClassName:MyclassName];//在里程中的顺序
    [setObject setObject:MyuserDefaults forKey:loginUser];
    [setObject setObject:firObject forKey:firKey];
    [setObject setObject:secObject forKey:secKey];
    [setObject setObject:thirObject forKey:ThirKey];
    [setObject setObject:fourObject forKey:fourKey];
    [setObject setObject:firObject forKey:fiveKey];
    [setObject setObject:sixObject forKey:sixKey];
    [setObject saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
        if (isSuccessful) {
        } else {
            //            NSLog(@"%@",error);
        }
    }];
}


@end
